package com.liu.demo1.testDemo;

/**
 * @author liusiyu
 * @ClassName TestLambda
 * @date 2021年12月22日 15:51
 */
public class TestLambda {

    //静态内部类
    static class Like2 implements ILike{

        @Override
        public void lambda() {
            System.out.println("I Like Lambda2");
        }
    }
    public static void main(String[] args) {
        ILike like = new Like();
        like.lambda();

        like = new Like2();
        like.lambda();

        //局部内部类
        class Like3 implements ILike{
            @Override
            public void lambda() {
                System.out.println("I Like Lambda3");
            }
        }

        like = new Like3();
        like.lambda();

        //匿名内部类
        like = new ILike() {
            @Override
            public void lambda() {
                System.out.println("I Like Lambda4");
            }
        };
        like.lambda();

        //lambda表达式
        like = () -> {
            System.out.println("I Like Lambda5");
        };
        like.lambda();

        like = () -> System.out.println("I Like Lambda6");
        like.lambda();

    }
}

interface ILike{
    void lambda();
}

class Like implements ILike{

    @Override
    public void lambda() {
        System.out.println("I Like Lambda1");
    }
}